<?php


namespace api\modules\v1\controllers;

use Yii;
use api\controllers\OnAuthController;
use common\models\common\Log;
use common\models\rbac\Action;

class LogController extends OnAuthController
{
    public $modelClass = '';

    /**
     * 不用进行登录验证的方法
     *
     * 例如： ['index', 'update', 'create', 'view', 'delete']
     * 默认全部需要验证
     *
     * @var array
     */

    /**
     * @api {get} v1/log/index
     * @return array
     * @throws \yii\mongodb\Exception
     * @api {post} ADDRESS
     * @apiName
     * @apiGroup
     * @apiParam {Number}
     * @apiParam {String}
     * @author loujie
     */
    public function actionIndex()
    {
        $params = Yii::$app->request->get();
        $params['project_id'] = $this->projectId;
        $page = $params['page'] ?? 1;
        $pageSize = $params['pageSize'] ?? 20;
        $data = Yii::$app->services->actionLog->getList($params, $page, $pageSize);
        return $data;
    }

    /**
     * @api {get} v1/log/view
     * @apiName
     * @apiGroup
     * @apiParam {Number}
     * @apiParam {String}
     * @author loujie
     * @param $id
     * @return array|\yii\db\ActiveRecord|\yii\mongodb\ActiveRecord|null
     */
    public function actionView($id)
    {
        $data = Yii::$app->services->actionLog->getDetail($id);
        return $data;
    }

}